// pages/order/order.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bg1: "change",
    bg2: "non-payment",
    id1: "",
    id2: "",
    id3:"id"
  },
  all(e) {
    this.setData({
      bg1: "change",
      bg2: "non-payment",
      id1: "",
      id2: "id"
    }),
      this.getallList()
  },
  payment(e) {
    this.setData({
      bg1: "all",
      bg2: "change",
      id2: "",
      id1: "id"
    }),
      this.getpartList()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let self = this;
    self.getallList()
  },
  //获取全部订单列表数据
  getallList: function() {
    let self = this;
    let userInfo = app.globalData.userInfo;
    wx.request({
      url: "http://localhost:3000/showOrder1",
      method: 'POST',
      data: {
        userName: userInfo.nickName,
      },
      success(res) {
        console.log("111111111")
        console.log(res.data)
        let result = res.data;
        if (result) {
          //赋值
          self.setData({
            allList: result
          })
        }
      }
    })
  },
  //获取待付款列表数据
  getpartList: function() {
    let self = this;
    wx.request({
      url: "http://localhost:3000/showOrder2",
      method: 'POST',
      data: {
        userName: "梅花开"
      },
      success(res) {
        console.log("111111111")
        console.log(res.data)
        let result = res.data;
        if (result) {
          //赋值
          self.setData({
            partList: result
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {
 
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})